package com.app.ryjy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 性别枚举
 */
@AllArgsConstructor
@Getter
public enum GenderEnum {
    // 不限
    NO_LIMIT("不限", 0, -1),
    // 男
    MALE("男", 1, -1),
    // 女
    FEMALE("女", 2, -1);

    private final String desc;
    private final int code;
    private final int bizCode;

    /**
     * 根据 bizCode 获取 code
     *
     * @param bizCode bizCode
     * @return code
     */
    public static int getCodeByBizCode(int bizCode) {
        for (GenderEnum gender : values()) {
            if (gender.getBizCode() == bizCode) {
                return gender.getCode();
            }
        }
        throw new RuntimeException("bizCode 不存在");
    }

    public static void main(String[] args) {
        System.out.println(GenderEnum.getCodeByBizCode(1));
    }
}